package cqrtplm.service;

import com.alibaba.fastjson.JSONObject;
import com.hustcad.plm.pdm.flowbusiness.model.entity.FlowObject;
import com.hustcad.plm.pdm.flowbusiness.model.entity.WorkFlowObjectPackage;
import com.hustcad.plm.pdm.user.model.dto.PdmUserDTO;
import com.hustcad.plm.pdm.workflow.model.entity.UserTaskDTO;
import com.hustcad.plm.pdm.workflow.model.entity.WorkFlow;
import com.ty.basic.entity.IdentifierEntity;
import com.ty.basic.entity.org.UserDO;
import cqrtplm.entity.FlowTaskClaimDO;
import org.flowable.engine.delegate.DelegateExecution;

import java.math.BigInteger;
import java.util.List;

/**
 * @author pieStar
 * @Date 2025/7/2 18:07
 */
public interface FlowControlService {
    void parallelNodeCheckListener(BigInteger workFlowContainerId, String nodeId);

    void chooseFLowBranch(BigInteger bigInteger, String expressionText, DelegateExecution execution);

    void transitionStage(String workFlowContainerId, String stageValue);

    String processTaskClaim(String taskDefKey, String workFlowContainerId, String taskId, UserDO user);

    FlowTaskClaimDO selectClaimMsgByTaskId(String taskId);

    /**
     * 获取流程模板
     * @param templateName
     * @return
     */
    WorkFlow getDefaultWorkFlow(String templateName);

    /**
     * 获取流程参与者
     * @param userNameList
     * @return
     */
    List<PdmUserDTO> getPdmUserDTOS(List<String> userNameList);

    void chooseFLowBranch2(BigInteger workFlowContainerId, String condition, String node);

    void checkInitiatorDepartmentBranch(BigInteger workFlowContainerId, String nodeId, String departmentCondition);

    void startIpdWorkFlow(JSONObject params);

    /**
     * 发起者角色分支判断
     * 根据发起者角色判断流程分支，清空不匹配分支的执行人
     * @param workFlowContainerId 工作流容器ID
     * @param nodeId 节点ID
     * @param roleCondition 角色条件表达式，如：role != '部门主管' 或 role == '部门主管'
     */
    void checkInitiatorRoleBranch(BigInteger workFlowContainerId, String nodeId, String roleCondition);

    Boolean checkIsNeedClaim(String taskId);

    void checkDepartmentSupervisor(BigInteger bigInteger, UserDO initiator,DelegateExecution execution);

    void checkMixture(BigInteger bigInteger, String nodeIdValue, String departmentConditionValue, String nodeId, String condition);

    /**
     * 检查物料的使用情况，被BOM引用则报错提示，图样代号衍生的物料码也需要校验
     * @param workFlowContainerId
     */
    void checkPartUsage(String workFlowContainerId);

    /**
     *  自动给流程节点添加人员
     * @param workFlowContainerId
     */
    void addTaskByFormData(String workFlowContainerId, String typeStr);

    /**
     *  检查表单数据
     * @param workFlowContainerId
     * @param expressionText
     */
    void checkFromData(String workFlowContainerId, String expressionText);

    /**
     *  根据表单中填写的字段自动给流程节点添加人。
     * @param workFlowContainerId
     */
    void autoAddTaskListByFormData(String workFlowContainerId, String valueStr);


    WorkFlowObjectPackage getWorkFlowContainerView(List<UserTaskDTO> userTaskList, WorkFlow workFlow, List<FlowObject> flowObjectList, List<PdmUserDTO> userList, String workflowName);

    IdentifierEntity startPlanChangWorkFlow(JSONObject param);

    void completedPlanChangWorkFlow(JSONObject param) throws Exception;

    void updateProjectChangeFlowName(String workFlowContainerId);

    void codeEnableProcessValidation(BigInteger workFlowContainerId);

    void checkWorkFlowPartData(BigInteger workFlowContainerId);

}
